home *** CD-ROM | disk | FTP | other *** search
- ;This subroutine will provide a standard interface to Lattice C (at least)
- ; to the interrupts provided. All interrupts using register (not segment)
- ; elements are provided for, but the program may be easily modified. The
- ; routine dynamically inserts the interupt code in the executable code. All
- ; communications done with the module are through external integers (again
- ; easy to modify if you desire to change this).
- ;
- ; To call from C the protocol is: = 0 = 0
- ;
- ; extern int intrpt();
- ; extern int intrp,r_ax,r_bx,r_cx,r_dx;
- ;
- ; /* assign r_ax, r_bx, r_cx, r_dx to the register values */
- ; /* assign intrp to the interupt number */
- ; intrpt();
- ;
- ; See the example in TSTC.C to see it in use. Please note that the routine
- ; works under DOS 1.1 with version 1.04, and under DOS 2.0 with the new C.OBJ
- ; generated from the C.ASM module stored under this BBS.
- ;
- ; B. K. Jenkins
- ;
- ;
- ;
- DGROUP GROUP DATA
- DATA SEGMENT WORD PUBLIC 'DATA'
-
- assume ds:dgroup
-
-
- ;definition of data exchange area for subroutine
- ; (NB communicate via c's char variables that contain
- ; correct values for interrupt number to be processed, and
- ; for the register set (ax,bx,cx,dx)
-
- public intrp
- public r_ax
- public r_bx
- public r_cx
- public r_dx
-
- intrp dw ? ;interrupt number
- r_ax dw ? ;value of ax for interrupt
- r_bx dw ? ;value of bx for interrupt
- r_cx dw ? ;value of cx for interrupt
- r_dx dw ? ;value of dx for interrupt
-
- DATA ends
-
- PGROUP GROUP PROG
-
- PROG SEGMENT BYTE PUBLIC 'PROG'
-
- assume cs:pgroup
-
- public INTRPT
-
- ;*****************************
-
- INTRPT proc near
-
- push bp ;save passed registers on stack
- push ax ; (NB. some are not really needed)
- push bx
- push cx
- push dx
-
- ;insert interupt command at INT_NO in code
- mov dx,intrp ;put interrupt number in dh code below
- mov dh,dl ; (lsb contains number discard msb)
- mov dl,0cdh ;code for INT (cdh) put in dl
- push ds ;change ds to cs
- push cs
- pop ds
- mov [int_no],dx ;put in interrupt command
- pop ds ;restore ds
-
- mov ax,r_ax ;move desired register values to
- mov bx,r_bx ;appropriate registers
- mov cx,r_cx
- mov dx,r_dx
-
- INT_NO: nop ;these two bytes are replaced with
- nop ;the interrupt command desired
- ; (necessary because cannot use INT
- ; with a variable parameter)
-
- mov dgroup:r_ax,ax ;move register values produced by
- mov dgroup:r_bx,bx ;interrupt back to register variables
- mov dgroup:r_cx,cx ;that C can use
- mov dgroup:r_dx,dx
-
- pop dx ;recover saved registers
- pop cx
- pop bx
- pop ax
- pop bp
-
- ret
-
- INTRPT endp
-
- PROG ends
-
- end
-
-
-
- end
-
-